﻿using Bilibili.Common;
using Bilibili.Common.Api;
using Bilibili.Common.Database;
using PCLUntils.Objects;

namespace Bilibili.WebClient.Common
{
    public sealed class ApiProvider : ApiProviderBase
    {
        private static ApiProvider instance;
        public static ApiProvider Instance => instance ??= new ApiProvider();
        private ApiProvider() => Init();
        private string _AccessKey;
        public override string AccessKey
        {
            get
            {
                if (_AccessKey.IsEmpty())
                    _AccessKey = SettingHelper.AccessKey;
                return _AccessKey;
            }
            set => _AccessKey = value;
        }
        private long _currentUserId;
        public override long CurrentUserId
        {
            get
            {
                if (_currentUserId.IsEmpty())
                    _currentUserId = SettingHelper.UserID;
                return _currentUserId;
            }
            set => _currentUserId = value;
        }
        protected override string ToMD5(string input) => input.ToMD5();
        public void Clear()
        {
            CurrentUserId = 0;
            AccessKey = string.Empty;
        }
    }
}